<f:view xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:aui="http://liferay.com/faces/aui"
	xmlns:c="http://java.sun.com/jsp/jstl/core" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:bridge="http://liferay.com/faces/bridge"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:example-cc="http://java.sun.com/jsf/composite/example-cc"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	
	
	<h:form id="workingHoursForm" styleClass="workingHoursForm" >
		<ui:include src="/jsf/appointment/common/appointment_information.xhtml" />
		<f:event listener="#{workingHoursController.loadData}" type="javax.faces.event.PreRenderComponentEvent" />
		<h:panelGroup styleClass="workingHoursTitle contentTitle" >
			<h:outputText value="Kalenderwoche: #{workingHoursController.calendarWeek}" 
						styleClass="workingHoursTitleValue contentTitleValue" />
			<h:outputText value="Datum von: #{workingHoursController.workingHoursDateMondayString} bis: #{workingHoursController.workingHoursDateSundayString}" 
						styleClass="workingHoursTitleValue contentTitleValue" />
			<p:commandButton value="" 
						title="Zeige vorherige Woche" 
						styleClass="electroOffice-button workingHoursButton workingHoursNavButton fontello-left-open" 
						actionListener="#{workingHoursController.navigateWeekBackward}" 
						ajax="false" />
			<p:commandButton value="" 
						title="Zeige nächste Woche" 
						styleClass="electroOffice-button workingHoursButton workingHoursNavButton fontello-right-open" 
						actionListener="#{workingHoursController.navigateWeekForward}" 
						ajax="false" />
			<p:commandButton value="Zur aktuellen Woche" 
						title="Zeige aktuelle Woche" 
						styleClass="electroOffice-button workingHoursButton" 
						actionListener="#{workingHoursController.navigateToCurrentWeek}" 
						ajax="false" />
			<h:panelGroup styleClass="navigationDatePicker" >
				<p:calendar value="#{workingHoursController.chosenDate}" id="popupButtonCal" showOn="button" />  
			    <p:commandButton value="Zeige" styleClass="electroOffice-button" actionListener="#{workingHoursController.showWeekByDate}" ajax="false" />
			</h:panelGroup>
		</h:panelGroup>
	    <p:dataTable var="workingHoursEntry" 
	    		value="#{workingHoursController.workingHourEntries}"
	    		styleClass="prodHours" >
	         
	        <p:column headerText="Mitarbeiter" styleClass="staff" >
	            <h:outputText value="#{workingHoursEntry.user.fullName}" />
	        </p:column>
	        
	        <p:column headerText="Mo" styleClass="timefield workday monday" >
	            <h:outputText value="#{workingHoursEntry.monday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Di" styleClass="timefield workday tuesday" >  
	            <h:outputText value="#{workingHoursEntry.tuesday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Mi" styleClass="timefield workday wednesday" >  
	            <h:outputText value="#{workingHoursEntry.wednesday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Do" styleClass="timefield workday thursday" >  
	            <h:outputText value="#{workingHoursEntry.thursday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Fr" styleClass="timefield workday friday" >  
	            <h:outputText value="#{workingHoursEntry.friday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Sa" styleClass="timefield weekendDay saturday" >  
	            <h:outputText value="#{workingHoursEntry.saturday.hours}" />
	        </p:column>
	        
	        <p:column headerText="So" styleClass="timefield weekendDay sunday" >  
	            <h:outputText value="#{workingHoursEntry.sunday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Total" styleClass="timefield total" >
	            <h:outputText value="#{workingHoursEntry.total}" />
	        </p:column>
	        
	        <p:column headerText="" styleClass="tools" >
	            <p:commandLink ajax="false" onclick="PF('editWorkingHours').show();return false;" >
					<h:graphicImage value="/img/edit.png" />
				</p:commandLink>
				<p:commandLink ajax="false" actionListener="#{workingHoursController.deleteWorkingHoursEntry}" rendered="#{!workingHoursEntry.isDefault}" >
					<p:confirm header="Bitte bestätigen" 
							message="Sind Sie sicher das sie diesen Eintrag löschen wollen?" 
							icon="ui-icon-alert" />
					<h:graphicImage value="/img/delete.png" />
				</p:commandLink>
				<p:confirmDialog global="true" showEffect="fade" hideEffect="explode">
			        <p:commandButton value="Ja" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			        <p:commandButton value="Nein" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			    </p:confirmDialog>
	        </p:column>
	        
	        <p:columnGroup type="footer">  
                <p:row>  
                    <p:column footerText="Arbeitsstunden Total" />  
                    <p:column footerText="#{workingHoursController.totalProdMonday}" />  
                    <p:column footerText="#{workingHoursController.totalProdTuesday}" />
                    <p:column footerText="#{workingHoursController.totalProdWednesday}" />
                    <p:column footerText="#{workingHoursController.totalProdThursday}" />
                    <p:column footerText="#{workingHoursController.totalProdFriday}" />
                    <p:column footerText="#{workingHoursController.totalProdSaturday}" />
                    <p:column footerText="#{workingHoursController.totalProdSunday}" />
                    <p:column footerText="#{workingHoursController.totalProdTotal}" />
                </p:row>
            </p:columnGroup>
	    </p:dataTable>
	    
	    <p:dialog header="Arbeitszeit erfassen" widgetVar="editWorkingHours" modal="true" draggable="false" resizable="false" >
		    <p:outputLabel for="users" value="Mitarbeiter:" />
	        <p:selectOneMenu id="users"
					value="#{workingHoursController.selectedUserId}"
					styleClass="electroOffice-dropdown workingHoursFormInput" 
					disabled="#{!empty workingHoursController.defaultWorkingHoursEntry.user}" >
				<f:selectItem itemLabel="Mitarbeiter wählen..." itemValue="-1" />
				<f:selectItems value="#{workingHoursController.userList}" />
			</p:selectOneMenu>
	        <p:outputLabel for="monday" value="Montag" />
	        <p:inputText id="monday" value="#{workingHoursController.defaultWorkingHoursEntry.monday.hours}" styleClass="workingHoursTextfield" />
	        <p:outputLabel for="tuesday" value="Dienstag" />
	        <p:inputText id="tuesday" value="#{workingHoursController.defaultWorkingHoursEntry.tuesday.hours}" styleClass="workingHoursTextfield" />
	        <p:outputLabel for="wednesday" value="Mittwoch" />
	        <p:inputText id="wednesday" value="#{workingHoursController.defaultWorkingHoursEntry.wednesday.hours}" styleClass="workingHoursTextfield" />
	        <p:outputLabel for="thursday" value="Donnerstag" />
	        <p:inputText id="thursday" value="#{workingHoursController.defaultWorkingHoursEntry.thursday.hours}" styleClass="workingHoursTextfield" />
	        <p:outputLabel for="friday" value="Freitag" />
	        <p:inputText id="friday" value="#{workingHoursController.defaultWorkingHoursEntry.friday.hours}" styleClass="workingHoursTextfield" />
	        <p:outputLabel for="saturday" value="Samstag" />
	        <p:inputText id="saturday" value="#{workingHoursController.defaultWorkingHoursEntry.saturday.hours}" styleClass="workingHoursTextfield weekendField" />
	        <p:outputLabel for="sunday" value="Sonntag" />
	        <p:inputText id="sunday" value="#{workingHoursController.defaultWorkingHoursEntry.sunday.hours}" styleClass="workingHoursTextfield weekendField" />
			<h:panelGroup>
				<p:commandButton value="Speichern" 
							title="Arbeitsstunden speichern" 
							styleClass="electroOffice-button workingHoursButton" 
							actionListener="#{workingHoursController.saveWorkingHoursEntry}" 
							ajax="false" />
				<p:commandButton value="Abbrechen" 
							title="Fenster schliessen und Arbeitsstunden verwerfen"
							styleClass="electroOffice-button workingHoursButton" 
							actionListener="#{workingHoursController.cancel}" 
							ajax="false" />
			</h:panelGroup>
		</p:dialog>
	</h:form>
</f:view>